package net.googlecode.morenko.task5.workers;

/**
 * The parent class for all kinds of workers, such as Employee, Manager, Director.
 */
public abstract class Worker {
    private int code;
    private String firstName;
    private String lastName;
    private int age;
    private int rate;
    private boolean bonus;
    private int bonusAmount;
    private int salary;
    protected Jobs post;
    /**
     * Constructor, creates object.
     * @param firstName objects first name.
     * @param lastName  objects second name.
     * @param code the personal unique code.
     */
    public Worker(String firstName, String lastName, int code) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.code = code;
    }

    /**
     * Set the age value.
     * @param age the age value.
     */
    public void setAge(int age) {
        this.age = (age > 0) ? age : 0;
    }

    /**
     * Set the rate value.
     * @param rate the rate value.
     */
    public void setRate(int rate) {
        this.rate = (rate > 0) ? rate : 0;
    }

    /**
     * Set is the person has bonus.
     * @param bonus true or false.
     */
    public void setBonus(boolean bonus) {
        this.bonus = bonus;
    }

    /**
     * Set the bonus value.
     * @param bonusAmount the value of bonus.
     */
    public void setBonusAmount(int bonusAmount) {
        this.bonusAmount = (bonusAmount > 0) ? bonusAmount : 0;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    /**
     * Get the age of the person.
     * @return persons age.
     */
    public int getAge() {
        return this.age;
    }

    /**
     * Get the rate of the person.
     * @return persons rate.
     */
    public int getRate() {
        return this.rate;
    }

    /**
     * Check is the person has bonus.
     * @return true or false.
     */
    public boolean isHaveBonus() {
        return this.bonus;
    }

    /**
     * Get bonus amount value.
     * @return bonus amount.
     */
    public int getBonusAmount() {
        return this.bonusAmount;
    }

    /**
     * Get the salary of the person.
     * @return salary.
     */
    public int getSalary() {
        return salary;
    }

    /**
     * Get the post of the person.
     * @return post.
     * @see Jobs
     */
    public Jobs getPost() {
        return post;
    }

    /**
     * Get the personal code of the person.
     * @return personal code.
     */
    public int getCode() {
        return code;
    }

    /**
     * Get the first name of the person.
     * @return first name.
     */
    public String getFirstName() {
        return firstName;
    }

    /**
     * Get the last name of the person.
     * @return last name.
     */
    public String getLastName() {
        return lastName;
    }

    /**
     * Overriden toString Objects method in order to output
     * information about the person.
     * @return information about the person.
     */
    public String toString() {
        return code + " " + firstName + " " + lastName + " " + salary;
    }
}
